<template>

  <div class="tab-bar-item" @click="Comclick" >
   <div  v-if="isActive">
      <slot name="active"></slot>
    </div>
     <div v-else>
        <slot name="item-icon"> </slot>
      </div>
    <div :style="activeStyle ">
      <slot name="item-text"></slot>
    </div>
  </div>
  <!--  </dvi>-->

  <!--  <dvi class="tab-bar-item">-->
  <!--    <img src="../../assets/img/TabBar/首页.gif" alt="">-->
  <!--    <div>分类</div>-->
  <!--  </dvi>-->

  <!--  <dvi class="tab-bar-item">-->
  <!--    <img src="../../assets/img/TabBar/首页.gif" alt="">-->
  <!--    <div>购物车</div>-->
  <!--  </dvi>-->
  <!--  <dvi class="tab-bar-item">-->
  <!--    <img src="../../assets/img/TabBar/首页.gif" alt="">-->
  <!--    <div>我的</div>-->
  <!--  </dvi>-->

</template>

<script>
export default {
  name: "TabBarItem",
  props:{
    path:String,
    activeColor:{
      type:String,
      default:'red',
    }
  },
  data() {
    return {

    }

  } ,
  computed:{
    isActive(){
      return this.$route.path.indexOf(this.path) !==-1;

    },
    activeStyle(){
      return this.isActive ? {color:this.activeColor} : '';
      // return this.isActive?{color:this.activeColor}:''
    }
  },
  methods:{
    Comclick(){
     this.$router.replace(this.path)

    }
  }
}
</script>

<style scoped>
.tab-bar-item {
  text-align: center;
  height: 49px;
  flex: 1;

}

.tab-bar-item img {
  margin-top: 3px;
  width: 24px;
  height: 24px;
  vertical-align: middle;
}


</style>